package com.hqyj.springBoot.modules.account.service.impl;

import com.hqyj.springBoot.modules.common.vo.Result;
import com.hqyj.springBoot.modules.account.dao.RoleResourceDao;
import com.hqyj.springBoot.modules.account.entity.RoleResource;
import com.hqyj.springBoot.modules.account.service.RoleResourceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class RoleResourceServiceImpl implements RoleResourceService {

    @Autowired
    private RoleResourceDao roleResourceDao;


    @Override
    public Result<RoleResource> insertRoleResource(RoleResource roleResource) {

        RoleResource temp = roleResourceDao.selectRoleResourceById(roleResource.getId());
        if (temp != null){
            return new Result<>(Result.ResultStatus.FAILED.code, "RoleResource is repeat");
        }
        roleResourceDao.insertRoleResource(roleResource);

        return new Result<>(Result.ResultStatus.SUCCESS.code, "Insert success",roleResource);
    }
}
